/*
 * Created on Apr 25, 2005
 */
package org.vectrics.recruiter.job;

import java.util.Comparator;

import org.vectrics.SystemException;

/**
 * @author MMoore
 */
public class JobCandidateCalculationChildScoreCompare implements Comparator {
	public static int COMPARE_SCORE = 0;
	public static int COMPARE_MAXIMUM_SCORE = 1;
	private int compareType = COMPARE_MAXIMUM_SCORE;
	
	/**
	 * 
	 */
	public JobCandidateCalculationChildScoreCompare() {
		super();
	}

	public int compare(Object o1, Object o2) {
		int result = 0;
		JobCandidateCalculationChildScore c1 = (JobCandidateCalculationChildScore)o1; 
		JobCandidateCalculationChildScore c2 = (JobCandidateCalculationChildScore)o2;
		if (this.compareType == COMPARE_MAXIMUM_SCORE) {
			result = c1.getMaximumScore().compareTo(c2.getMaximumScore());
		} else if (this.compareType == COMPARE_SCORE) {
			result = c1.getChildScore().compareTo(c2.getChildScore());
		} else {
			throw new SystemException("Unknown compare type: " + this.compareType);
		}
		if (result == 0) {
			result = c1.getId().compareTo(c2.getId());
		}
		return(result);
	}

	/**
	 * @return Returns the compareType.
	 */
	public int getCompareType() {
		return compareType;
	}
	/**
	 * @param compareType The compareType to set.
	 */
	public void setCompareType(int compareType) {
		this.compareType = compareType;
	}
}
